//
//  ImgSelectCell.m
//  HWFinal
//
//  Created by student on 2021/12/10.
//  Copyright © 2021 demo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ImgSelectCell.h"


@interface ImgSelectCell ()

@property(strong, nonatomic) UIImageView* iv;

@property(strong, nonatomic) ModelController* mc;

@end

@implementation ImgSelectCell

//直接设置图片
-(void)setImage: (UIImage*)img
{
    self.img = img;
    
    self.iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
    self.iv.image = self.img;
    self.iv.backgroundColor = [UIColor lightGrayColor];
    self.iv.contentMode = UIViewContentModeScaleAspectFill;
    self.iv.clipsToBounds = YES;
    [self addSubview:self.iv];
}

//通过本地的filePath加载视频缩略图
-(void)setVideoImage: (NSString*)filePath
{
    self.mc = [ModelController getInstance];
    self.img = [self.mc getRawImg:[NSURL fileURLWithPath:filePath]];
    
    //添加缩略图
    self.iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
    self.iv.image = self.img;
    self.iv.backgroundColor = [UIColor lightGrayColor];
    self.iv.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:self.iv];
    self.iv.contentMode = UIViewContentModeCenter;
    self.iv.clipsToBounds = YES;
    
    //添加播放标志
    UIImageView* subiv = [[UIImageView alloc]initWithFrame:CGRectMake(self.bounds.size.width / 2 - 30, self.bounds.size.height / 2 - 30, 60, 60)];
    subiv.layer.cornerRadius = 30;
    subiv.backgroundColor = [UIColor lightGrayColor];
    subiv.image = [UIImage imageNamed:@"bofang.png" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
    [self.iv addSubview:subiv];
}

@end
